<?
include "conf/db_connect.php";

if(isset($_GET['articol_id'])){
	$ip = $_SERVER['REMOTE_ADDR'];
	$sql = "select * from voturi_articole where ip = '$ip' and articol_id = '{$_GET['articol_id']}'";
	$res = mysql_query($sql);
	if(!mysql_num_rows($res)){
		mysql_query("update articole set nota = nota+".$_GET['nota'].", note = note+1 where id = '{$_GET['articol_id']}'");
		$sql = "insert into voturi_articole set ip = '$ip', articol_id = '{$_GET['articol_id']}'";
		mysql_query($sql);
	}
	$art = mysql_fetch_array(mysql_query("select nota, note from articole where id = '{$_GET['articol_id']}'"));
	echo str_replace(".00","",number_format($art['nota']/$art['note'],2,"."," "))." / 5";
}
?>